package com.mall.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ModelAttribute;

import com.mall.bean.User;
import com.mall.bean.view.UserView;
import com.mall.dao.UserDao;
import com.mall.service.IUserService;

@Service("userService")
public class UserServiceImpl implements IUserService{
	//注入
	@Resource
	private UserDao userDao;	
	//注册用户
	public String register(@Param("username") String username,@Param("age") String age,@Param("school") String school,@Param("phone") String phone,@Param("email") String email,@Param("password") String password,@Param("password1") String password1) {
		// TODO Auto-generated method stub
		User User = new User();	
		UserView userView = new UserView();
					return "success";
		} 	
	//登录用户
	//手机号码
	@Override
	public User login(String phone,String password) {
		//System.out.println(phone);
		
		  User user = new User();
		  user.setPhone(phone);
		  user.setPassword(password);
		 
		
		//System.out.println("service："+user.getPhone());
		return userDao.findUser(user);
		
	}
	//邮箱
	@Override
	public User login1(String email,String password) {
					
		System.out.println(email+";"+password);
		User user = new User();
		user.setEmail(email);
		user.setPassword(password);
		return userDao.findUser1(user);
		
	}

	@Override
	public String register(@ModelAttribute UserView userView) {
		
		System.out.println("密码："+userView.getPassword());
		if (userView != null && (userView.getPassword().equals(userView.getPassword1()))) {			
			
			
			
			userDao.addUser(userView);
			
			return "success";
		}
		return "";
	
	}
	
	//查询唯一性
	public int checkUser(String phone) {
		
		int status = userDao.checkUser(phone);

			return status;		
	}
	@Override
	public int checkUser2(String email) {
		int status = userDao.checkUser2(email);
		
			return status;		
	}

	
		


	

	



	



	

	
	
}
